package com.mustafa.payment.dao;

import com.mustafa.payment.model.OrderModel;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface OrderMapper {

    @Select("SELECT * FROM orders")
    List<OrderModel> findAll();

    @Select("SELECT * FROM orders WHERE `orderNo` = #{orderNo}")
    OrderModel getOrder(@Param("orderNo") String orderNo);

    @Update("update orders set `payResult` = 1 where `orderNo` = #{orderNo}")
    int setPayResult(@Param("orderNo") String orderNo);

    @Insert("insert into orders (`orderNo`, `uid`, `productName`, `payMethod`, `encryptionKey`, `encryptionIv`, `payResult`) values (#{orderNo}, #{uid}, #{productName}, #{payMethod}, #{encryptionKey}, #{encryptionIv}, 0)")
    int createOrder(OrderModel orderModel);
}
